<?php /*
	*/ ?>
<?php include("system/config.inc.php");
$donotinclude = 1;
if(!isset($_SESSION['adminuserid']))
{
	header("location:index.php?msg=logfirst");
	die();
}
//// UPDATE the record
$p_email ="";
$p_currancy = "";	
$p_desc="";
$action=1;

 
		$sql = "select * from tblpaypalsettings";
		$result = $obj_db->select($sql);
			
		if($result)
		{
			foreach($result as $row)
			{
				$p_email = $row['varpaypalemail'];
				$p_currancy = $row['varcurrency'];
				$p_desc=$row['txtdesc'];
				$action=2;
			}
		}
		
		if(isset($_REQUEST['Submit']) && trim($_REQUEST['Submit']) == "Update")
		{
			$email = $_REQUEST['email'];
			$curr = $_REQUEST['currancy'];
			$desc=$_REQUEST['desc'];
			$sql = "UPDATE `tblpaypalsettings`
				SET `varpaypalemail` = '$email',
				`varcurrency`='$curr',
				`txtdesc`='$desc'";
			
			$upd=$obj_db->edit($sql);
			$action=1;
			
			header("location:paypalsetting.php?msg=edit");
			die();
		}
/////////////////// END  of EDIT ///////////////////////////////////

?>
<?php include("inc/header.php");?>
<body>
<script language="javascript" type="text/javascript">
function check()
{
	var cond=true;
	if(document.paypal.email.value.length==0)
	{
		alert("Please enter Email.");
		if(cond==true)
		{
			document.paypal.email.focus();
		}
		cond=false;
		return false;
	}	
	if(document.paypal.currancy.value==0)
	{
		alert("Please select currancy.");
		if(cond==true)
		{
			document.paypal.currancy.focus();
		}
		cond=false;
		return false;
	}	
	
	else if(!checkMail(document.paypal.email.value))
	{
		alert("Email must contain an email address.\n");
		if(cond==true)
		{
			document.paypal.email.focus();
		}
		cond=false;
		return false;
	}
	
}	
function checkMail(email)
{
	var x = email;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) 
	{
	 return true;
	}
	else 
	{
	  return false;
	}
}
</script>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" class="middlebackground">
  <tr>
    <td colspan="3" valign="top" align="center"><?php include(INC."top.inc.php");?></td>
  </tr>
  <tr>
    <td width="2%">&nbsp;</td>
    <td width="96%">
	<form action="" method="post" enctype="multipart/form-data" name="paypal">
      <table width="60%" align="center" cellpadding="2" cellspacing="2" class="border">
        <tr class="top">
          <td align="center" class="bg1"><strong>Paypal Settings...</strong></td>
        </tr>
        <tr >
          <td><table width="100%"  border="0" align="center" cellpadding="2" cellspacing="2">

              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td width="6%">&nbsp;</td>
                <td width="42%" align="right" class="sltimg">Paypal E-Mail </td>
                <td width="2%">:</td>
                <td width="50%"><label>
                  <input type="text" name="email" value="<?php echo $p_email;?>"/>
                </label></td>
              </tr>
              
              <tr>
                <td>&nbsp;</td>
                <td align="right" class="sltimg">Currency</td>
                <td>:</td>
                <td><select name="currancy" id="currancy">
                  <option value="0">Select Currency</option>
                  <?php 
						$sql="select * from tblcurrencies";
						$resman = $obj_db->select($sql);
						if(count($resman)>0)
						{
							for($m=0;$m<count($resman);$m++)
							{
								
							
					?>
                  <option value="<?php echo $resman[$m]['intid'];?>"<?php if($resman[$m]['intid'] == $p_currancy){echo "selected";}else{echo "";} ?>>
                    <?php echo $resman[$m]['vartitle'];?>
                    </option>
                  <?php 
							}
						}
					?>
                </select></td>
              </tr>
             
              <tr>
                <td>&nbsp;</td>
                <td align="right" valign="top">Description</td>
                <td valign="top">:</td>
                <td><textarea name="desc" cols="30" rows="4" id="desc"><?php echo $p_desc;?></textarea></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td colspan="4" align="center"><input name="Submit" type="submit" class="btn" value="Update" onClick="return check();"/></td>
              </tr>
          </table></td>
        </tr>
      </table>
    
	</form>
</td>
    <td width="2%">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3" align="center">&nbsp;</td>
  </tr>
</table>

</body>
</html>
